﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SisLegal.Model;

namespace SisLegal.Administrative
{
    public partial class ListView : System.Web.UI.Page
    {
        AdministrativeManager fiscalFolder;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                fiscalFolder = new AdministrativeManager();
                RstTable.DataSource = fiscalFolder.Paginate(1);
                RstTable.DataBind();

                double xx = Convert.ToDouble(fiscalFolder.Count() / 10);
                double tt = Math.Ceiling(xx);

                List<Item> items = new List<Item>();
                for (int x = 1; x <= tt; x++)
                {
                    items.Add(new Item() { NumPage = x });
                }
                Repeater_Paginate.DataSource = items;
                Repeater_Paginate.DataBind();
            }
        }

        protected void Paginate_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "Paginate")
            {
                String num = e.CommandArgument.ToString();
                fiscalFolder = new AdministrativeManager();
                RstTable.DataSource = fiscalFolder.Paginate(Convert.ToInt32(num));
                RstTable.DataBind();
            }
        }
    }
}